{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### The `OutputWidget`"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The output widget can be used to display rich output. `IHaskell.Display` provides functions to create such rich displays from raw data."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false,
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "{-# LANGUAGE OverloadedStrings #-}\n",
    "import IHaskell.Display.Widgets\n",
    "import IHaskell.Display\n",
    ":t plain\n",
    ":t html\n",
    ":t jpg\n",
    ":t svg\n",
    ":t latex\n",
    ":t javascript\n",
    ":t many"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The `Output` widget is meant to be used through the functions:\n",
    "\n",
    "+ `appendOutput`: Append more output to the widget.\n",
    "+ `clearOutput`: Clear the output widget ASAP.\n",
    "+ `clearOutput_`: Clear the output widget on next use of `appendOutput`.\n",
    "+ `replaceOutput`: Clear then append."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "import Text.Printf\n",
    "o <- mkOutputWidget -- Make output widget\n",
    "setField o Width 500\n",
    "o -- Display output widget\n",
    "\n",
    "fmt = \"<font color=\\\"%s\\\"><marquee direction=\\\"%s\\\" style=\\\"background:%s\\\">%s</marquee></font>\"\n",
    "add fg bg dir txt = appendOutput o $ html $ printf fmt fg dir bg txt\n",
    "\n",
    "add \"WHITE\" \"RED\" \"left\" \"The <b>OUTPUT</b> Widget\"\n",
    "add \"WHITE\" \"BLUE\" \"right\" \"Is really <b>SIMPLE</b>\"\n",
    "add \"WHITE\" \"GREEN\" \"left\" \"Use it as an <b>UPDATABLE</b> display</b>\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Currently, the output widget doesn't support displaying other widgets inside it. It does so in IPython, but not in IHaskell."
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Haskell",
   "language": "haskell",
   "name": "haskell"
  },
  "language_info": {
   "codemirror_mode": "ihaskell",
   "file_extension": ".hs",
   "name": "haskell",
   "version": "7.10.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
